home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / park_thi.swf / scripts / DefineSprite_279_clip20 / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2010-08-12  |  1.4 KB  |  57 lines

  1. function attack()
  2. {
  3.    var _loc3_ = _parent.attachMovie("rays","rays" + _parent.getNextHighestDepth(),_parent.getNextHighestDepth());
  4.    _loc3_.angle = this._rotation;
  5.    _parent.globalToLocal(point);
  6.    trace(point.x);
  7.    _loc3_._x = point.x;
  8.    _loc3_._y = point.y;
  9.    _loc3_.target = target;
  10.    _loc3_.onEnterFrame = function()
  11.    {
  12.       this._x -= 5 * Math.cos(this.angle * 3.141592653589793 / 180);
  13.       this._y -= 5 * Math.sin(this.angle * 3.141592653589793 / 180);
  14.       this._rotation = this.angle + 90;
  15.       if(this._x > 400 || this._x < -400 || this._y < -300 || this._y > 300)
  16.       {
  17.          this.removeMovieClip();
  18.       }
  19.       if(this.hitTest(target))
  20.       {
  21.          target.health = 0;
  22.          this.removeMovieClip();
  23.       }
  24.    };
  25. }
  26. var target;
  27. var attackRate = 25;
  28. var timer = 0;
  29. var health = 100;
  30. onEnterFrame = function()
  31. {
  32.    if(_root.userCar == "")
  33.    {
  34.       target = _parent.valet_mc;
  35.    }
  36.    else
  37.    {
  38.       target = _parent[_root.userCar];
  39.    }
  40.    this._rotation = Math.atan2(this._y - target._y,this._x - target._x) * 180 / 3.141592653589793;
  41.    if(_currentframe == 1)
  42.    {
  43.       gotoAndStop(3);
  44.    }
  45.    if(_root.userCar != "")
  46.    {
  47.       if(this.hitTest(target) && this._currentframe != _totalframes)
  48.       {
  49.          this.health -= 20;
  50.          if(this.health <= 0)
  51.          {
  52.             this.gotoAndStop(_totalframes);
  53.          }
  54.       }
  55.    }
  56. };
  57.